<?php
/**
 * 企业相关的数据操作类
 * jzzmly
 */
if(!defined("SYSTEM_TIME")){
	define("SYSTEM_TIME", isset ( $_SERVER ['REQUEST_TIME'] ) ? $_SERVER ['REQUEST_TIME'] : time ());
}
class Libs_EDbHand
{
	//add
	public static function addEJob(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('firm_id','class_id','section_id','name','en_name','digest','need_num','province_id','city_id','add_time','update_time','sort_order');
		
		$insertId = Libs_DBHelper::insertItem(array(
		'db' => $db,
		'tableName' => 'e_job',
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return $insertId;
	}
	
	//update form field
	public static function updateEJob(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('class_id','section_id','name','en_name','digest','need_num','province_id','city_id','update_time','sort_order');
		
		Libs_DBHelper::updateItem(array(
		'db' => $db,
		'tableName' => 'e_job',
		'where' => $param['where'],
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return 1;
	}
	
	//add job class
	public static function addEJobClass(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('firm_id','name','en_name','digest','sort_order');
		
		$insertId = Libs_DBHelper::insertItem(array(
		'db' => $db,
		'tableName' => 'e_job_class',
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return $insertId;
	}
	
	//update form field
	public static function updateEJobClass(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('name','en_name','digest','sort_order');
		
		Libs_DBHelper::updateItem(array(
		'db' => $db,
		'tableName' => 'e_job_class',
		'where' => $param['where'],
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return 1;
	}
	
	//add form field
	public static function addFormField(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('firm_id','name','default');
		
		$insertId = Libs_DBHelper::insertItem(array(
		'db' => $db,
		'tableName' => 'e_form_field',
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return $insertId;
	}
	
	//update form field
	public static function updateFormField(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('name','default');
		
		Libs_DBHelper::updateItem(array(
		'db' => $db,
		'tableName' => 'e_form_field',
		'where' => $param['where'],
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return 1;
	}
	
	
	//add resume score itime
	public static function addResumeScoreItem(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('firm_id','name','max_score','weight','sort_order');
		
		$insertId = Libs_DBHelper::insertItem(array(
		'db' => $db,
		'tableName' => 'e_resume_score_set',
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return $insertId;
	}
	
	//update resume score itime
	public static function updateResumeScoreItem(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('name','max_score','weight','sort_order');
		
		Libs_DBHelper::updateItem(array(
		'db' => $db,
		'tableName' => 'e_resume_score_set',
		'where' => $param['where'],
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return 1;
	}
	
	//add user class
	public static function addSubUser(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('name','passwd','firm_tag','firm_id','section_id','real_name','mobile','add_time','e_desc');
		
		$insertId = Libs_DBHelper::insertItem(array(
		'db' => $db,
		'tableName' => 'e_sub_user',
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return $insertId;
	}
	
	//update resume subuser data
	public static function updateSubUser(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('name','passwd','real_name','section_id','mobile','e_desc');
		
		Libs_DBHelper::updateItem(array(
		'db' => $db,
		'tableName' => 'e_sub_user',
		'where' => $param['where'],
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return 1;
	}
	
	//add section class
	public static function addESection(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('name','firm_id','digest');
		
		$insertId = Libs_DBHelper::insertItem(array(
		'db' => $db,
		'tableName' => 'e_section',
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return $insertId;
	}
	
	//update firm section data
	public static function updateESection(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('name','digest');
		
		Libs_DBHelper::updateItem(array(
		'db' => $db,
		'tableName' => 'e_section',
		'where' => $param['where'],
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return 1;
	}
	
	//add tags class
	public static function addETags(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('name','firm_id','sort_order');
		
		$insertId = Libs_DBHelper::insertItem(array(
		'db' => $db,
		'tableName' => 'e_tags',
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return $insertId;
	}
	
	//update firm tags data
	public static function updateETags(array $param)
	{
		$arr = $param['arr'];
		if(!$arr) return 0;
		$db = Db_Resume::instance();
		//field
		$colArr = array('name','sort_order');
		
		Libs_DBHelper::updateItem(array(
		'db' => $db,
		'tableName' => 'e_tags',
		'where' => $param['where'],
		'addItem' => $arr,
		'colArr' => $colArr,
		'debug' => $param['debug'],
		));
		return 1;
	}
	
	//get firm section arr
	public static function getFirmSectionArr(array $param)
	{
		$outArr = '';
		$firmId = intval($param['firmId']);
		if(!$firmId) return '';
		
		$db = Db_Resume::instance();
		$sql = "Select id,name From `e_section` Where status=0 and firm_id='{$firmId}'";
		$data = $db->getAll($sql);
		if($data){
			foreach ($data as $val) {
				$outArr[$val['id']] = $val['name'];
			}
		}
		return $outArr;
	}
}

?>
